home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / 80x0393.zip / NET_SN.ASM < prev    next >
Assembly Source File  |  1992-07-30  |  3KB  |  100 lines

  1. %PAGESIZE 55,200
  2. %TITLE "NetWare serial number routine"
  3. ; Net_SN.Asm
  4. ;
  5. ; written on Mon  06-01-1992 by Ed Beroset
  6. ; released to the public domain
  7. ;
  8. ; I've tested this code with Netware 386 version 3.11, 
  9. ; but it may also work with 2.15.  It wasn't documented 
  10. ; for 2.15, but it may still have existed.                                                             
  11. ;
  12.  
  13.   .MODEL SMALL
  14.   IDEAL
  15.  
  16.  STACK 100h
  17.  DATASEG
  18.  
  19. STDOUT    = 1   ; handle for stdout
  20.  
  21.     STRUC SNREQBUFF
  22.     Length      DW  1       ; request structure length - 2
  23.     Function    DB  12h     ; function number of GetNetworkSerialNumber
  24.     ENDS SNREQBUFF
  25.  
  26.     STRUC SNREPLYBUFF
  27.     Length      DW  6       ; reply structure length - 2
  28.     NetSN       DD  0       ; network serial number in big endian packed BCD
  29.     AppNumber   DW  0       ; Application number in same format
  30.     ENDS SNREPLYBUFF
  31.  
  32.     U_Request SNREQBUFF    <>
  33.     U_Reply   SNREPLYBUFF  <>
  34.     SerialNum  DB  "00000000",0dh, 0ah
  35.     SerialLen  = $ - SerialNum
  36.  
  37.  CODESEG
  38. ;
  39. ; Test code gets network serial number and prints it to stdout
  40. ;
  41. Start:
  42.   mov  ax,@data
  43.   mov  ds,ax                ; set up the data segment
  44.   call NetworkSN
  45. Exit:
  46.   mov  ah,04ch              ; return with error code preset in AL
  47.   int  21h
  48.  
  49. ;
  50. ; here's the Network stuff
  51. ;
  52. PROC    NetworkSN
  53.     push    ds
  54.     push    si
  55.     push    di
  56.     push    es
  57.     push    dx
  58.     push    cx
  59.  
  60.     lea     si,[U_Request]      ; prepare to request data
  61.     lea     di,[U_Reply  ]      ; prepare to receive data
  62.     mov     ax,ds
  63.     mov     es,ax
  64.     mov     ah,0e3h             ; Get File Server Serial Number
  65.     int     21h
  66.     jc      @@NoMore
  67.  
  68.     lea     si,[U_Reply.NetSN]  ; point ds:si at binary data
  69.     lea     di,[SerialNum]      ; and point es:di at target ASCII string
  70.     mov     cx,4                ; loop four times (once for each SN digit pair)
  71.     cld                         ; count up
  72.  
  73. @@convbyte:
  74.     lodsb                       ; read a byte
  75.     aam     16                  ; convert to two-digit BCD in ah,al
  76.     xchg    ah,al               ; swap so that memory image will be correct
  77.     or      ax,3030h            ; convert both to ASCII numbers
  78.     stosw                       ; put 'em in our table
  79.     loop    @@convbyte
  80.  
  81.     lea     dx,[SerialNum]      ; we're going to point ds:dx to string
  82.     mov     cx,SerialLen        ; load the length of the string
  83.     mov     bx,STDOUT           ; print to STDOUT
  84.     mov     ah,40h              ; DOS function to print string
  85.     int     21h                 ; do it
  86.     mov     al,0                ; return with appropriate error code
  87.  
  88. @@NoMore:
  89.     pop     cx
  90.     pop     dx
  91.     pop     es
  92.     pop     di
  93.     pop     si
  94.     pop     ds
  95.     ret
  96.  
  97. ENDP        NetworkSN   ;end of proc
  98.  
  99.   END Start
  100.